var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var a = t("SpriteLoad"),
    i = t("Util"),
    s = t("Prefabs"),
    c = t("ConfS"),
    l = t("fightManager"),
    u = t("fun"),
    p = t("build"),
    f = cc._decorator,
    d = f.ccclass,
    h =
        (f.property,
        (function (t) {
            function e() {
                return (null !== t && t.apply(this, arguments)) || this;
            }
            return (
                n(e, t),
                (e.prototype.onEnable = function () {
                    (this.fight = this.getComponent(l.default)),
                        (this.builds = []),
                        (this.ruins = []),
                        this.initbuilds();
                }),
                (e.prototype.onDisable = function () {
                    this.builds.forEach(function (t) {
                        return t.node.destroy();
                    }),
                        this.ruins.forEach(function (t) {
                            return t.destroy();
                        }),
                        (this.builds = null),
                        (this.ruins = null);
                }),
                (e.prototype.initbuilds = function () {
                    for (var t = l.default.mapdata, e = 0; e < t.jianzhu.length; e++) {
                        var o = t.jianzhu[e],
                            n = c.DatasManager.JianzhuDatasById[o],
                            r = s.instantiate("build");
                        (r.x = t.weizhi[2 * e]), (r.y = t.weizhi[2 * e + 1]);
                        var a = r.getComponent(p.default);
                        (a.manager = this),
                            (a.data = n),
                            (r.active = !0),
                            this.builds.push(a),
                            this.fight.bodys.addChild(r);
                    }
                }),
                (e.prototype.removebuild = function (t, e) {
                    if (e && i.isRandom(t.npcdata.diaoluogailv)) {
                        var o = t.node.x - l.default.inst.camera.node.parent.x,
                            n = t.node.y - l.default.inst.camera.node.parent.y,
                            r = u.randomFall(t.npcdata.diaoluobao);
                        l.default.inst.view.add(r.cashType, r.currency, o, n);
                    }
                    i.removeArray(this.builds, t), t.node.destroy();
                }),
                (e.prototype.add_build_ruins = function (t, e) {
                    var o = s.instantiate("ruins");
                    (o.x = t.node.x + t.data.RuinOffset[0]),
                        (o.y = t.node.y + t.data.RuinOffset[1]),
                        this.ruins.push(o),
                        this.fight.bg.addChild(o),
                        (o.getComponent(a.default).url.value = t.data.RuinID);
                    var n = s.instantiate("buildBomb");
                    (n.x = t.node.x + t.data.DeathEffOffset[0]),
                        (n.y = t.node.y + t.data.DeathEffOffset[1]),
                        this.fight.bg.addChild(n);
                    var r = s.instantiate("建筑燃烧冒烟");
                    (r.x += t.node.x), (r.y += t.node.y), this.fight.bodys.addChild(r), this.removebuild(t, e);
                }),
                (e = r([d], e))
            );
        })(cc.Component));
o.default = h;
